Public Interest::Data Ethics & Practice
Reading through the initial drafts of narrative around the measures – purpose, contexts – suggested some structure we might consider and I’ve made a very draft-y example to advance our thinking.
This isn’t remotely final – I want to review more of your work this week as I know it will raise and clarify more ideas – but is meant to help you “see” how it might all fit.
The Grammar of Graphcis: All data visualizations map data to aesthetic attributes (location, shape, color) of geometric objects (lines, points, bars)
Scales control the mapping from data to aesthetics and provide tools to read the plot (axes, legends). Geometric objects are drawn in a specific coordinate system.
A plot can contains statistical transformations of the data (counts, means, medians) and faceting can be used to generate the same plot for different subsets of the data.
ggplot(data, aes(x=, y=, color=, shape=, size=)) +
geom_point() # or geom_histogram() or geom_boxplot() or geom_line() or geom_bar(), etc.
aes()
function maps columns of the data frame to
aesthetic properties of geometric shapes to be plotted.ggplot()
defines the plot; the geoms
show
the data+
For example:
ggplot(data, aes(x = var1, y = var2)) +
geom_point(aes(color = var3)) +
geom_smooth(color = "red") +
labs(title = "Helpful Title",
x = "x-axis label")
ggplot
+ geoms
facet_wrap()
facet_grid()
coord_cartesian
allows us to zoom in on a plotcoord_flip
allows us to flip the x and y axisFirst go to slack and copy the practice script for today (week4script.R) into your weeklymaterials/scripts folder from last week. Then open an RStudio session using the weeklymaterials.Rproj file.